using System;

namespace Slaks.Graphs.Algorithms.ExperimentalDistances
{
	public class MCSadapted
	{
		/// <summary>
		/// MCSadapted
		/// </summary>
		/// <param name="one"></param>
		/// <param name="two"></param>
		/// <returns></returns>
		public static double DistMCS4VertexEdgeCountAdapted(Graph one, Graph two)
		{
			Graph maxCommonSubgraph = (MaxCommonSubGraphVertexEdgeCount.GetMCS(one, two));
			double commonSize = GraphDistances.GetGraphSizeVertexEdgeCount(maxCommonSubgraph);
			double oneSize = GraphDistances.GetGraphSizeVertexEdgeCount(one);
			double twoSize = GraphDistances.GetGraphSizeVertexEdgeCount(two);

			if (Math.Abs(commonSize - oneSize) < Math.Abs(commonSize - twoSize))
			{
				if (commonSize < oneSize) return 1 - commonSize/oneSize;
				return 1 - commonSize/twoSize;
			}
			else
			{
				if (commonSize < twoSize) return 1 - commonSize/twoSize;
				return 1 - commonSize/oneSize;
			}
		}

		/// <summary>
		/// MCSadapted
		/// </summary>
		/// <param name="one"></param>
		/// <param name="two"></param>
		/// <returns></returns>
		public static double DistMCS4VertexEdgeFrequencyAdapted(Graph one, Graph two)
		{
			Graph maxCommonSubgraph = (MaxCommonSubGraphVertexEdgeFrequency.GetMCS(one, two));
			double commonSize = GraphDistances.GetGraphSizeVertexEdgeFrequency(maxCommonSubgraph);
			double oneSize = GraphDistances.GetGraphSizeVertexEdgeFrequency(one);
			double twoSize = GraphDistances.GetGraphSizeVertexEdgeFrequency(two);

			if (Math.Abs(commonSize - oneSize) < Math.Abs(commonSize - twoSize))
			{
				if (commonSize < oneSize) return 1 - commonSize/oneSize;
				return 1 - commonSize/twoSize;
			}
			else
			{
				if (commonSize < twoSize) return 1 - commonSize/twoSize;
				return 1 - commonSize/oneSize;
			}
		}

	}
}